﻿@model HanGu.Entity.Group
@{
    Layout = null;
    var CurentUser = Session["CurentUser"] as HanGu.Entity.CurrentUserDTO;
    var isUpdate = false;
    if (CurentUser != null)
    {
        isUpdate = CurentUser.Roles.Where(c => c.ID == "CustomerGroup_4").FirstOrDefault() != null;
    }
}
<script>
    function validateCallbackForGroups(form, navTabAjaxDone) {
        $("#SelectorHighSearch").remove();
        var panel = $("#GroupMembers");
        var formPanel = $("#GroupMessage");

        var ckbMemberSelected = panel.find("#SelectedMember").find("input:checked");
        var ckbMemberSelecting = panel.find("#SelectingMember").find("input:checked");
        var MemberSelectings = ckbMemberSelecting.map(function () {
            return $(this).val();
        }).get().join(',');
        var MemberSelecteds = ckbMemberSelected.map(function () {
            return $(this).val();
        }).get().join(',');
        formPanel.find("#MemberSelected").val(MemberSelecteds);
        formPanel.find("#MemberSelecting").val(MemberSelectings);       
        return validateCallback(form, navTabAjaxDone);
    }

</script>
<div class="pageContent">
    <div class="tabs" currentindex="0" eventtype="chick">
        <div class="tabsHeader">
            <div class="tabsHeaderContent">
                <ul>
                    <li><a><span>群信息(@Model.GroupName)</span></a></li>
                    <li><a href="/CustomerInfo/Default/Index?action=SelectorForGroup&groupID=@Model.ID" class="j-ajax">
                        <span>群成员</span></a></li>
                </ul>
            </div>
        </div>
        <div class="tabsContent">
            <div id="GroupMessage">
                <form method="post" id="GroupCreateFrom" action="CustomerGroup/Default/create?OpID=@ViewData["OperateID"]" class="pageForm" onsubmit="return validateCallbackForGroups(this, navTabAjaxDone);">
                @Html.ValidationSummary(true)
                <div class="pageFormContent" layouth="100">
                    <div>
                        @Html.HiddenFor(model => model.ID)
                        @Html.HiddenFor(model => model.MemberID)
                        @Html.Hidden("MemberSelected")
                        @Html.Hidden("MemberSelecting")
                        <p>
                            <label>
                                组名:</label>
                            @if (isUpdate)
                            {
                                @Html.TextBoxFor(model => model.GroupName)
                            }
                            else
                            { 
                                @Html.HiddenFor(model => model.GroupName)
                                @MvcHtmlString.Create(Model.GroupName)
                            }
                        </p>
                        <p style="width: 100%; height: 30px;">
                            <label>
                                备注:</label>
                            @if (isUpdate)
                            {
                                @Html.TextAreaFor(model => model.Remark, new { style = "width:99%; height:100px;" })
                            }
                            else
                            { 
                                @Html.HiddenFor(model => model.Remark)
                                @MvcHtmlString.Create(Model.Remark)
                            }
                        </p>
                    </div>
                </div>
                <div class="formBar">
                    <ul>
                        <li>
                            <div class="buttonActive">
                                <div class="buttonContent">
                                    <button type="submit">
                                        提交</button></div>
                            </div>
                        </li>
                        <li>
                            <div class="button">
                                <div class="buttonContent">
                                    <button type="button" class="close">
                                        取消</button></div>
                            </div>
                        </li>
                    </ul>
                </div>
                </form>
            </div>
            <div id="GroupMembers" layoutH="60">
            </div>
        </div>
        <div class="tabsFooter">
            <div class="tabsFooterContent">
            </div>
        </div>
    </div>
</div>
<script>
    function ShowSelectedAll() {
        $("#SelectedMember").loadUrl("CustomerGroup/Default/MemberSelected/@Model.ID?showall=true");
    }
    function ShowSelectingAll() {
        $("#SelectingMember").loadUrl("CustomerGroup/Default/MemberSelecting/@Model.ID?showall=true");
    }
</script>
